/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jjsoft.celularessuc.gco.mdl;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author javila
 */
@Entity
@Table(catalog = "celularessuccom", schema = "public")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Transferencia.findAll", query = "SELECT t FROM Transferencia t"),
    @NamedQuery(name = "Transferencia.findByIdTransferencia", query = "SELECT t FROM Transferencia t WHERE t.idTransferencia = :idTransferencia"),
    @NamedQuery(name = "Transferencia.findByFecha", query = "SELECT t FROM Transferencia t WHERE t.fecha = :fecha"),
    @NamedQuery(name = "Transferencia.findByTotal", query = "SELECT t FROM Transferencia t WHERE t.total = :total"),
    @NamedQuery(name = "Transferencia.findByEstado", query = "SELECT t FROM Transferencia t WHERE t.estado = :estado")})
public class Transferencia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_transferencia", nullable = false)
    private Integer idTransferencia;
    @Temporal(TemporalType.DATE)
    private Date fecha;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(precision = 17, scale = 17)
    private Double total;
    private Integer estado;
    @OneToMany(mappedBy = "idTransferencia", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<Detalletransferencia> detalletransferenciaList;
    @JoinColumn(name = "id_usuario", referencedColumnName = "nick")
    @ManyToOne(fetch = FetchType.EAGER)
    private Usuario idUsuario;
    @JoinColumn(name = "id_sucursal_destino", referencedColumnName = "idsucursal")
    @ManyToOne(fetch = FetchType.EAGER)
    private Sucursal idSucursalDestino;
    @JoinColumn(name = "id_sucursal_origen", referencedColumnName = "idsucursal")
    @ManyToOne(fetch = FetchType.EAGER)
    private Sucursal idSucursalOrigen;

    public Transferencia() {
    }

    public Transferencia(Integer idTransferencia) {
        this.idTransferencia = idTransferencia;
    }

    public Integer getIdTransferencia() {
        return idTransferencia;
    }

    public void setIdTransferencia(Integer idTransferencia) {
        this.idTransferencia = idTransferencia;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    @XmlTransient
    @JsonIgnore
    public List<Detalletransferencia> getDetalletransferenciaList() {
        return detalletransferenciaList;
    }

    public void setDetalletransferenciaList(List<Detalletransferencia> detalletransferenciaList) {
        this.detalletransferenciaList = detalletransferenciaList;
    }

    public Usuario getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(Usuario idUsuario) {
        this.idUsuario = idUsuario;
    }

    public Sucursal getIdSucursalDestino() {
        return idSucursalDestino;
    }

    public void setIdSucursalDestino(Sucursal idSucursalDestino) {
        this.idSucursalDestino = idSucursalDestino;
    }

    public Sucursal getIdSucursalOrigen() {
        return idSucursalOrigen;
    }

    public void setIdSucursalOrigen(Sucursal idSucursalOrigen) {
        this.idSucursalOrigen = idSucursalOrigen;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTransferencia != null ? idTransferencia.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transferencia)) {
            return false;
        }
        Transferencia other = (Transferencia) object;
        if ((this.idTransferencia == null && other.idTransferencia != null) || (this.idTransferencia != null && !this.idTransferencia.equals(other.idTransferencia))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jjsoft.celularessuc.gco.mdl.Transferencia[ idTransferencia=" + idTransferencia + " ]";
    }
    
}
